package bairui.international.model.domain.jpa;

import com.lianjing.sh.project.authority.model.domain.jpa.TB_RoleBase;

/**
 *
 * (角色)TB_Role
 *
 * @说明
 * <pre>

 * </pre>
 *
 * @see Help_TB_Role#inheritance() 继承体系信息
 *
 */
@org.hibernate.annotations.DynamicInsert
@org.hibernate.annotations.DynamicUpdate

@javax.persistence.Entity(name="t_role")
@com.lianjing.sh.processing.info.annotation.GenerateInfoModel
@SuppressWarnings("serial")
@com.lianjing.sh.model.common.annotation.Comment("角色")
@com.lianjing.sh.processing.info.annotation.InfoComment("角色")
public class TB_Role
 extends TB_RoleBase
 implements 
	com.lianjing.sh.model.common.stardard.TableModel<Long>,
	com.sh_lianjing.state.HasStatable,
	java.io.Serializable

{

	
	
	/**
	 * 必须属性赋值接口
	 */
	public static interface MustProperties{
		/** 角色名称 */
		public String getRoleName();
		/** 角色状态 */
		public com.lianjing.sh.project.authority.model.status.State_Role getRoleState();
		/** 名称 */
		public String getName();
	}
	
	/**
	 * 为必须属性赋值
	 */
	public TB_Role properties(MustProperties properties) {
		this.setRoleName(properties.getRoleName());
		this.setRoleState(properties.getRoleState());
		this.setName(properties.getName());
		return this;
	}
	
	/**
	 *	必须属性构造函数
	 */
	public TB_Role(MustProperties properties) {
		this.properties(properties);
	}
	
	
	/**
	 * 可选单属性赋值接口
	 */
	public static interface OptionalSingleProperties{
		/** 角色备注 */
		public String getRoleComment();
		/** 备注 */
		public String getComment();
	}
	
	/**
	 * 为可选单属性赋值
	 */
	public TB_Role properties(OptionalSingleProperties properties) {
		this.setRoleComment(properties.getRoleComment());
		this.setComment(properties.getComment());
		return this;
	}
	
	
	
	public TB_Role(MustProperties must, OptionalSingleProperties optionalSingle) {
		this.properties(must);
		this.properties(optionalSingle);
	}
	
	/**
	 * 仅当前必须属性赋值接口
	 */
	public static interface CurrentMustProperties{
		/** 名称 */
		public String getName();
	}
	
	/**
	 * 为仅当前必须属性赋值
	 */
	public TB_Role properties(CurrentMustProperties properties) {
		this.setName(properties.getName());
		return this;
	}
	
	/**
	 * 仅当前可选单属性赋值接口
	 */
	public static interface CurrentOptionalSingleProperties{
		/** 备注 */
		public String getComment();
	}
	
	/**
	 * 为仅当前可选单属性赋值
	 */
	public TB_Role properties(CurrentOptionalSingleProperties properties) {
		this.setComment(properties.getComment());
		return this;
	}
	
	public TB_Role(
		@lombok.NonNull com.lianjing.sh.project.authority.model.domain.jpa.TB_RoleBase bean,
		CurrentMustProperties mustProperties,
		CurrentOptionalSingleProperties optionalProperties
	) {
		this(bean);
		this.properties(mustProperties);
		this.properties(optionalProperties);
	}
	
	public TB_Role(
		@lombok.NonNull com.lianjing.sh.project.authority.model.domain.jpa.TB_RoleBase bean
	) {
		update(bean);
	}
	
	public TB_Role update(com.lianjing.sh.project.authority.model.domain.jpa.TB_RoleBase bean){
		this.setId(bean.getId());
		this.setCreateTime(bean.getCreateTime());
		this.setModifyTime(bean.getModifyTime());
		this.setOrderValue(bean.getOrderValue());
		this.setAuthorities(bean.getAuthorities());
		this.setRoleGroups(bean.getRoleGroups());
		this.setCreator(bean.getCreator());
		this.setLastModifier(bean.getLastModifier());
		this.setRoleName(bean.getRoleName());
		this.setRoleComment(bean.getRoleComment());
		this.setRoleState(bean.getRoleState());
		this.setOperatorBases(bean.getOperatorBases());
		this.setNoticeBases(bean.getNoticeBases());
		return this;
	}
	
	
	/**
	 * 更新属性内部类
	 */
	public abstract class UpdateProperties {
	
		public UpdateProperties() throws Exception {
			Integer orderValue = getOrderValue(TB_Role.this);
			if(isOverride_getOrderValue){
				TB_Role.this.setOrderValue(orderValue);
			}
	
			java.util.List<com.lianjing.sh.project.authority.model.domain.jpa.TB_Authority> authorities = getAuthorities(TB_Role.this);
			if(isOverride_getAuthorities){
				TB_Role.this.setAuthorities(authorities);
			}
	
			java.util.List<com.lianjing.sh.project.authority.model.domain.jpa.TB_RoleGroup> roleGroups = getRoleGroups(TB_Role.this);
			if(isOverride_getRoleGroups){
				TB_Role.this.setRoleGroups(roleGroups);
			}
	
			String roleName = getRoleName(TB_Role.this);
			if(isOverride_getRoleName){
				TB_Role.this.setRoleName(roleName);
			}
	
			String roleComment = getRoleComment(TB_Role.this);
			if(isOverride_getRoleComment){
				TB_Role.this.setRoleComment(roleComment);
			}
	
			com.lianjing.sh.project.authority.model.status.State_Role roleState = getRoleState(TB_Role.this);
			if(isOverride_getRoleState){
				TB_Role.this.setRoleState(roleState);
			}
	
			java.util.List<com.lianjing.sh.project.authority.model.domain.jpa.TB_OperatorBase> operatorBases = getOperatorBases(TB_Role.this);
			if(isOverride_getOperatorBases){
				TB_Role.this.setOperatorBases(operatorBases);
			}
	
			java.util.List<com.lianjing.sh.project.authority.model.domain.jpa.TB_NoticeBase> noticeBases = getNoticeBases(TB_Role.this);
			if(isOverride_getNoticeBases){
				TB_Role.this.setNoticeBases(noticeBases);
			}
	
			String name = getName(TB_Role.this);
			if(isOverride_getName){
				TB_Role.this.setName(name);
			}
	
			String comment = getComment(TB_Role.this);
			if(isOverride_getComment){
				TB_Role.this.setComment(comment);
			}
	
			java.util.List<bairui.international.model.domain.jpa.TB_Admin> admins = getAdmins(TB_Role.this);
			if(isOverride_getAdmins){
				TB_Role.this.setAdmins(admins);
			}
		}
	
		public TB_Role up(){
			return TB_Role.this;
		}
	
		/** 排序值 */
		private boolean isOverride_getOrderValue = true;
		public Integer getOrderValue(TB_Role it) throws Exception { 
			isOverride_getOrderValue = false; 
			return null;
		}
		/** 权限 */
		private boolean isOverride_getAuthorities = true;
		public java.util.List<com.lianjing.sh.project.authority.model.domain.jpa.TB_Authority> getAuthorities(TB_Role it) throws Exception { 
			isOverride_getAuthorities = false; 
			return null;
		}
		/** 角色组 */
		private boolean isOverride_getRoleGroups = true;
		public java.util.List<com.lianjing.sh.project.authority.model.domain.jpa.TB_RoleGroup> getRoleGroups(TB_Role it) throws Exception { 
			isOverride_getRoleGroups = false; 
			return null;
		}
		/** 角色名称 */
		private boolean isOverride_getRoleName = true;
		public String getRoleName(TB_Role it) throws Exception { 
			isOverride_getRoleName = false; 
			return null;
		}
		/** 角色备注 */
		private boolean isOverride_getRoleComment = true;
		public String getRoleComment(TB_Role it) throws Exception { 
			isOverride_getRoleComment = false; 
			return null;
		}
		/** 角色状态 */
		private boolean isOverride_getRoleState = true;
		public com.lianjing.sh.project.authority.model.status.State_Role getRoleState(TB_Role it) throws Exception { 
			isOverride_getRoleState = false; 
			return null;
		}
		/** 操作者基础 */
		private boolean isOverride_getOperatorBases = true;
		public java.util.List<com.lianjing.sh.project.authority.model.domain.jpa.TB_OperatorBase> getOperatorBases(TB_Role it) throws Exception { 
			isOverride_getOperatorBases = false; 
			return null;
		}
		/** 通知基础 */
		private boolean isOverride_getNoticeBases = true;
		public java.util.List<com.lianjing.sh.project.authority.model.domain.jpa.TB_NoticeBase> getNoticeBases(TB_Role it) throws Exception { 
			isOverride_getNoticeBases = false; 
			return null;
		}
		/** 名称 */
		private boolean isOverride_getName = true;
		public String getName(TB_Role it) throws Exception { 
			isOverride_getName = false; 
			return null;
		}
		/** 备注 */
		private boolean isOverride_getComment = true;
		public String getComment(TB_Role it) throws Exception { 
			isOverride_getComment = false; 
			return null;
		}
		/** 管理员 */
		private boolean isOverride_getAdmins = true;
		public java.util.List<bairui.international.model.domain.jpa.TB_Admin> getAdmins(TB_Role it) throws Exception { 
			isOverride_getAdmins = false; 
			return null;
		}
	
	}
	
	
	/**
	 * 构造函数
	 */
	public TB_Role() {
	}
	
	public TB_Role(
		@lombok.NonNull Long id
	) {
		this.setId(id);
	}
	
	public TB_Role(
		@lombok.NonNull TB_Role bean
	) {
		this.setId(bean.getId());
		this.setCreateTime(bean.getCreateTime());
		this.setModifyTime(bean.getModifyTime());
		this.setOrderValue(bean.getOrderValue());
		this.setAuthorities(bean.getAuthorities());
		this.setRoleGroups(bean.getRoleGroups());
		this.setCreator(bean.getCreator());
		this.setLastModifier(bean.getLastModifier());
		this.setRoleName(bean.getRoleName());
		this.setRoleComment(bean.getRoleComment());
		this.setRoleState(bean.getRoleState());
		this.setOperatorBases(bean.getOperatorBases());
		this.setNoticeBases(bean.getNoticeBases());
		this.setName(bean.getName());
		this.setComment(bean.getComment());
		this.setAdmins(bean.getAdmins());
	}
	
	

	


	/**
	 * 属性
	 */
	@com.lianjing.sh.model.common.annotation.Comment("名称")
	@com.lianjing.sh.processing.info.annotation.InfoComment("名称")
	@javax.persistence.Column(name="name", unique=true, nullable=false, length=20)
	private String name;

	@com.lianjing.sh.model.common.annotation.Comment("备注")
	@com.lianjing.sh.processing.info.annotation.InfoComment("备注")
	@javax.persistence.Column(name="comment", length=500)
	private String comment;

	@com.lianjing.sh.model.common.annotation.Comment("管理员")
	@com.lianjing.sh.processing.info.annotation.InfoComment("管理员")
	@com.querydsl.core.annotations.QueryInit("*.*.*")
	@javax.persistence.ManyToMany()
	private java.util.List<bairui.international.model.domain.jpa.TB_Admin> admins;

	/** get[名称] */
	public String getName() {
		return this.name;
	}

	/** get[备注] */
	public String getComment() {
		return this.comment;
	}

	/** get[管理员] */
	public java.util.List<bairui.international.model.domain.jpa.TB_Admin> getAdmins() {
		return this.admins;
	}

	/** set[名称] */
	public void setName(String name) {
		this.name = name;
	}

	/** set[备注] */
	public void setComment(String comment) {
		this.comment = comment;
	}

	/** set[管理员] */
	public void setAdmins(java.util.List<bairui.international.model.domain.jpa.TB_Admin> admins) {
		this.admins = admins;
	}


	/** add[Admins] */
	public TB_Role addAdmins(bairui.international.model.domain.jpa.TB_Admin ... admins){
		if(this.admins == null){
			this.admins = new java.util.ArrayList<>();
		}
		for(bairui.international.model.domain.jpa.TB_Admin bean : admins){
			this.admins.add(bean);
		}
		return this;
	}
	
	/** remove[Admins] */
	public TB_Role removeAdmins(bairui.international.model.domain.jpa.TB_Admin ... admins){
		if(this.admins == null){
			return this;
		}
		for(bairui.international.model.domain.jpa.TB_Admin bean : admins){
			this.admins.remove(bean);
		}
		return this;
	}
	
	/**
	 * contains[Admins]
	 *
	 * 全部输入都包含：返回 true
	 * 输入中有至少有一个不包含：返回 false
	 */
	public boolean containsAdmins(bairui.international.model.domain.jpa.TB_Admin ... admins){
		if(this.admins == null || admins==null || admins.length<=0){
			return false;
		}
		return this.admins.containsAll(java.util.Arrays.asList(admins));
	}
	

	
	
	

	/**
	 * 复写 hashCode
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		return prime * result + ((this.getId() == null) ? 0 : this.getId().hashCode());
	}
	
	/**
	 * 复写 equals
	 */
	@Override
	public boolean equals(Object obj) {
		if (this == obj){
			return true;
		}
		if (obj == null){
			return false;
		}
		if (getClass() != obj.getClass()){
			return false;
		}
		TB_Role other = (TB_Role) obj;
		if (this.getId() == null) {
			return false;
		} else if (!this.getId().equals(other.getId())){
			return false;
		}
		return true;
	}
	

	/**
	 * 用来覆盖toString()的输出
	 */
	@javax.persistence.Transient
	private String toString;
	
	public void setToString(String toString) {
		this.toString = toString;
	}
	
	/**
	 * 复写 toString
	 */
	@Override
	public String toString() {
		if(null != this.toString){
			return this.toString;
		}
		String name = this.getName();
		if(null != name){
			return String.valueOf(name);
		}
		return super.toString();
	}	

	@javax.persistence.PrePersist
	public void prePersist() {
		com.lianjing.sh.web.security.authority.login.LoginUserInfo userInfo = com.lianjing.sh.web.security.authority.login.Util_Login.getInfo();
		Object user = null == userInfo ? null : userInfo.getUser();
		this.setCreateTime(new java.util.Date());
		this.setModifyTime(new java.util.Date());
		this.setCreator((com.lianjing.sh.project.authority.model.domain.jpa.TB_OperatorBase)user);
		this.setLastModifier((com.lianjing.sh.project.authority.model.domain.jpa.TB_OperatorBase)user);
	}
	
	@javax.persistence.PreUpdate
	public void preUpdate() {
		com.lianjing.sh.web.security.authority.login.LoginUserInfo userInfo = com.lianjing.sh.web.security.authority.login.Util_Login.getInfo();
		Object user = null == userInfo ? null : userInfo.getUser();
		this.setModifyTime(new java.util.Date());
		this.setLastModifier((com.lianjing.sh.project.authority.model.domain.jpa.TB_OperatorBase)user);
	}

	/**
	 * 状态相关
	 */
	public com.lianjing.sh.project.authority.model.status.State_Role state(){
		return this.getRoleState();
	}


}
